package cn.wit.test;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class DemoJsp extends HttpServlet{
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String ip = req.getRemoteAddr();
		
		Date date = new Date();
		
		DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		
		String dateFormat = format.format(date);
		
//		//往浏览器输出内容
//		PrintWriter writer = resp.getWriter();
//		
//		writer.write("<html>");
//		
//		writer.write("<body>");
//		
//		writer.write("<h3>"+dateFormat+ip+"</h3>");
//		
//		writer.write("</body>");
//		
//		writer.write("</html>");
		
		req.setAttribute("message", dateFormat+ip);
		
		req.getRequestDispatcher("welcome.jsp").forward(req, resp);
		
		
	}

}
